﻿using System;
using SharpSqlAnalyzer.nodes;

namespace SharpSqlAnalyzer.stmt
{
	// Token: 0x02000092 RID: 146
	public class TCreateFunctionStmt : TRoutine
	{
		// Token: 0x060003E8 RID: 1000 RVA: 0x002FA6EE File Offset: 0x002F88EE
		public TCreateFunctionStmt(EDbVendor dbvendor) : base(dbvendor)
		{
			this.sqlstatementtype = ESqlStatementType.sstcreatefunction;
		}

		// Token: 0x060003E9 RID: 1001 RVA: 0x002FA702 File Offset: 0x002F8902
		private new void buildsql()
		{
		}

		// Token: 0x060003EA RID: 1002 RVA: 0x002FA704 File Offset: 0x002F8904
		private new void clear()
		{
		}

		// Token: 0x060003EB RID: 1003 RVA: 0x002FA706 File Offset: 0x002F8906
		private new string getasprettytext()
		{
			return "";
		}

		// Token: 0x060003EC RID: 1004 RVA: 0x002FA70D File Offset: 0x002F890D
		private void iterate(TVisitorAbs pvisitor)
		{
		}

		// Token: 0x060003ED RID: 1005 RVA: 0x002FA70F File Offset: 0x002F890F
		public TObjectName getStoredProcedureName()
		{
			return this.functionName;
		}

		// Token: 0x17000074 RID: 116
		// (get) Token: 0x060003EE RID: 1006 RVA: 0x002FA717 File Offset: 0x002F8917
		// (set) Token: 0x060003EF RID: 1007 RVA: 0x002FA71F File Offset: 0x002F891F
		public new TObjectName EndLabelName
		{
			get
			{
				return this.endlabelName;
			}
			set
			{
				this.endlabelName = value;
			}
		}

		// Token: 0x060003F0 RID: 1008 RVA: 0x002FA728 File Offset: 0x002F8928
		public TObjectName getFunctionName()
		{
			return this.functionName;
		}

		// Token: 0x17000075 RID: 117
		// (get) Token: 0x060003F1 RID: 1009 RVA: 0x002FA730 File Offset: 0x002F8930
		// (set) Token: 0x060003F2 RID: 1010 RVA: 0x002FA738 File Offset: 0x002F8938
		public string SharedLibraryName
		{
			get
			{
				return this.sharedLibraryName;
			}
			set
			{
				this.sharedLibraryName = value;
			}
		}

		// Token: 0x17000076 RID: 118
		// (get) Token: 0x060003F3 RID: 1011 RVA: 0x002FA741 File Offset: 0x002F8941
		// (set) Token: 0x060003F4 RID: 1012 RVA: 0x002FA749 File Offset: 0x002F8949
		public TConstant FunctionDefinition
		{
			get
			{
				return this._functionDefinition;
			}
			set
			{
				this._functionDefinition = value;
			}
		}

		// Token: 0x17000077 RID: 119
		// (get) Token: 0x060003F5 RID: 1013 RVA: 0x002FA752 File Offset: 0x002F8952
		// (set) Token: 0x060003F6 RID: 1014 RVA: 0x002FA75A File Offset: 0x002F895A
		public TConstant ProcedureLanguage
		{
			get
			{
				return this.procedureLanguage;
			}
			set
			{
				this.procedureLanguage = value;
			}
		}

		// Token: 0x060003F7 RID: 1015 RVA: 0x002FA763 File Offset: 0x002F8963
		private void redshiftFunctionDefinition(TCustomSqlStatement psql, TCreateFunctionSqlNode createFunctionNode)
		{
		}

		// Token: 0x060003F8 RID: 1016 RVA: 0x002FA765 File Offset: 0x002F8965
		private void snowflakeFunctionDefinition(TCustomSqlStatement psql, TCreateFunctionSqlNode createFunctionNode)
		{
		}

		// Token: 0x060003F9 RID: 1017 RVA: 0x002FA768 File Offset: 0x002F8968
		public override int doParseStatement(TCustomSqlStatement psql)
		{
			if (this.rootNode == null)
			{
				return -1;
			}
			TCreateFunctionSqlNode tcreateFunctionSqlNode = (TCreateFunctionSqlNode)this.rootNode;
			base.doParseStatement(psql);
			this.functionName = tcreateFunctionSqlNode.FunctionName;
			this.procedureLanguage = tcreateFunctionSqlNode.ProcedureLanguage;
			if (this.procedureLanguage != null)
			{
				base.setRoutineLanguageInConstant(this.procedureLanguage);
				base.setRoutineLanguage(this.procedureLanguage.ToString());
			}
			this.ParameterDeclarations = tcreateFunctionSqlNode.Parameters;
			if (this.ParameterDeclarations != null)
			{
				for (int i = 0; i < this.ParameterDeclarations.size(); i++)
				{
					this.TopStatement.SymbolTable.Push(new TSymbolTableItem(9, this, this.ParameterDeclarations.getParameterDeclarationItem(i)));
					TObjectName parameterName = this.ParameterDeclarations.getParameterDeclarationItem(i).ParameterName;
				}
			}
			base.setReturnDataType(tcreateFunctionSqlNode.ReturnDataType);
			if (tcreateFunctionSqlNode.Stmt != null)
			{
				tcreateFunctionSqlNode.Stmt.doParse(this, ESqlClause.unknown);
				this.BodyStatements.add(tcreateFunctionSqlNode.Stmt.Stmt);
			}
			else if (tcreateFunctionSqlNode.Blcok != null)
			{
				tcreateFunctionSqlNode.Blcok.Stmts.doParse(this, ESqlClause.unknown);
				for (int j = 0; j < tcreateFunctionSqlNode.Blcok.Stmts.size(); j++)
				{
					this.BodyStatements.add(tcreateFunctionSqlNode.Blcok.Stmts.getStatementSqlNode(j).Stmt);
				}
			}
			if (this.ParameterDeclarations != null)
			{
				for (int k = 0; k < this.ParameterDeclarations.size(); k++)
				{
					this.TopStatement.SymbolTable.Pop();
				}
			}
			if (tcreateFunctionSqlNode.SharedLibraryName != null)
			{
				this.sharedLibraryName = tcreateFunctionSqlNode.SharedLibraryName.ToString();
			}
			this._functionDefinition = tcreateFunctionSqlNode.FunctionDefinition;
			if (this._functionDefinition != null)
			{
				base.setRoutineBodyInConstant(this._functionDefinition);
				base.setRoutineBody(this._functionDefinition.ToString());
			}
			this.endlabelName = tcreateFunctionSqlNode.EndLabelName;
			return 0;
		}

		// Token: 0x060003FA RID: 1018 RVA: 0x002FA945 File Offset: 0x002F8B45
		public override void accept(TParseTreeVisitor v)
		{
			v.preVisit(this);
			v.postVisit(this);
		}

		// Token: 0x060003FB RID: 1019 RVA: 0x002FA955 File Offset: 0x002F8B55
		public override void acceptChildren(TParseTreeVisitor v)
		{
			v.preVisit(this);
			if (this.ParameterDeclarations != null)
			{
				this.ParameterDeclarations.acceptChildren(v);
			}
			this.BodyStatements.acceptChildren(v);
			v.postVisit(this);
		}

		// Token: 0x060003FC RID: 1020 RVA: 0x002FA985 File Offset: 0x002F8B85
		public void setFunctionName(TObjectName functionName)
		{
			this.functionName = functionName;
		}

		// Token: 0x040010C9 RID: 4297
		private TObjectName endlabelName;

		// Token: 0x040010CA RID: 4298
		private TObjectName functionName;

		// Token: 0x040010CB RID: 4299
		private string sharedLibraryName;

		// Token: 0x040010CC RID: 4300
		private TConstant _functionDefinition;

		// Token: 0x040010CD RID: 4301
		private TConstant procedureLanguage;
	}
}
